library(tidyverse)
library(readxl)
path = "files/Excel Challenge 4th August.xlsx"
input = read_excel(path, range = "B2:C8")
test = read_excel(path, range = "E2:F5")
result = input %>%
separate_rows(Customers, sep = "; ") %>%
mutate(Customers = str_trim(Customers)) %>%
mutate(count = n(), .by = c(Customers, Date)) %>%
filter(count > 1) %>%
distinct() %>%
summarise(`Repeat Customers` = str_c(Customers, collapse = "; "), .by = Date)
identical(result, test)
# [1] TRUECrispo - Excel Challenge 31 2024
excel-challenges
weekly-exercises
Easy Sunday Excel Challenge

Challenge Description
Easy Sunday Excel Challenge
⭐ Problem Solution Customers Date Repeat Customers Carl
Solutions
Logic:
Reads the workbook range needed for the challenge
Aggregates or ranks values at the correct grouping level
Builds the intermediate helper columns that drive the final answer
Uses direct text-pattern extraction instead of manual cleanup
Strengths:
- The R solution stays compact and mirrors the workbook logic closely.
Areas for Improvement:
- The code assumes the workbook layout and named ranges remain stable.
Gem:
- The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd
path = "files/Excel Challenge 4th August.xlsx"
input = pd.read_excel(path, usecols="B:C", skiprows = 1, nrows = 6)
test = pd.read_excel(path, usecols="E:F", skiprows = 1, nrows= 3)
test.columns = test.columns.str.replace('.1', '')
result = input.copy()
result['Customers'] = result['Customers'].str.split('; ')
result = result.explode('Customers')
result['Customers'] = result['Customers'].str.strip()
result['count'] = result.groupby(['Customers', 'Date'])['Customers'].transform('count')
result = result[result['count'] > 1].drop_duplicates()
result = result.groupby('Date')['Customers'].apply(lambda x: '; '.join(x)).reset_index(name='Repeat Customers')
print(result.equals(test)) # TrueLogic:
Reads the workbook range needed for the challenge
Aggregates or ranks values at the correct grouping level
Strengths:
- The Python version keeps the same rule in a direct pandas-oriented workflow.
Areas for Improvement:
- As with the R version, any workbook layout change would require small adjustments.
Gem:
- The implementation stays close to the stated challenge instead of adding unnecessary complexity.
Difficulty Level
This task is moderate:
It combines familiar Excel-style logic with at least one non-trivial reshape, grouping, or parsing step.
The answer depends on getting the output layout exactly right.